package leetcode;

public class Q0069 {
    public int mySqrt(int x) {
        if (x == 0 || x == 1) return x;
        long l = 1;
        long r = x;
        while (l < r) {
            long mid = l + r >> 1;
            if (mid * mid > x) r = mid;
            else l = mid + 1;
        }
        return (int) l - 1;
    }
}
